#include "wxsgenericdirctrl.h"
#include <wx/dirctrl.h>

namespace {
  wxsRegisterItem<wxsGenericDirCtrl> Reg( _T( "GenericDirCtrl" ), _T( "磁盘控件" ), wxsTWidget, _T( "对话框" ), 90 );
  WXS_ST_BEGIN( wxsGenericDirCtrlStyles, _T( "" ) )
  WXS_ST_CATEGORY( "wxGenericDirCtrl" )
  WXS_ST( wxDIRCTRL_DIR_ONLY )
  WXS_ST( wxDIRCTRL_3D_INTERNAL )
  WXS_ST( wxDIRCTRL_SELECT_FIRST )
  WXS_ST( wxDIRCTRL_SHOW_FILTERS )
  WXS_ST( wxDIRCTRL_EDIT_LABELS )
  WXS_ST_DEFAULTS()
  WXS_ST_END()
  WXS_EV_BEGIN( wxsGenericDirCtrlEvents )
  WXS_EVI( EVT_CMD_DIRCTRL_SELECTIONCHANGED, wxEVT_DIRCTRL_SELECTIONCHANGED, wxTreeEvent, SelectionChanged )
  WXS_EVI( EVT_CMD_DIRCTRL_FILEACTIVATED, wxEVT_DIRCTRL_FILEACTIVATED, wxTreeEvent, FileActivated )
  WXS_EV_END()
}

wxsGenericDirCtrl::wxsGenericDirCtrl( wxsItemResData* Data ):
  wxsWidget( Data, &Reg.Info, wxsGenericDirCtrlEvents, wxsGenericDirCtrlStyles ), DefaultFilter( 0 ) {}


void wxsGenericDirCtrl::OnBuildCreatingCode() {
  switch( GetLanguage() ) {
  case wxsCPP: {
    AddHeader( _T( "<wx/dirctrl.h>" ), GetInfo().ClassName, 0 );
    Codef( _T( "%C(%W, %I, %n, %P, %S, %T, %n, %d, %N);\n" ), DefaultFolder.wx_str(), Filter.wx_str(), DefaultFilter );
    BuildSetupWindowCode();
    return;
  }
  case wxsUnknownLanguage:
  default: {
    wxsCodeMarks::Unknown( _T( "wxsGenericDirCtrl::OnBuildCreatingCode" ), GetLanguage() );
  }
  }
}

wxObject* wxsGenericDirCtrl::OnBuildPreview( wxWindow* Parent, long Flags ) {
  wxGenericDirCtrl* Preview = new wxGenericDirCtrl( Parent, GetId(), DefaultFolder, Pos( Parent ), Size( Parent ), Style(), Filter, DefaultFilter );
  return SetupWindow( Preview, Flags );
}

void wxsGenericDirCtrl::OnEnumWidgetProperties( M_Code_unused long Flags ) {
  WXS_SHORT_STRING( wxsGenericDirCtrl, DefaultFolder, _T( "Default Folder" ), _T( "defaultfolder" ), _T( "" ), true )
  WXS_SHORT_STRING( wxsGenericDirCtrl, Filter, _T( "Filter" ), _T( "filter" ), _T( "" ), true )
  WXS_LONG( wxsGenericDirCtrl, DefaultFilter, _T( "Default Filter" ), _T( "defaultfilter" ), 0 )
}
